package com.example.controller;


import com.example.dao.IKeysDao;
import com.example.pojo.KeysPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class ProviderController {

    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private IKeysDao iKeysDao;

    @GetMapping("/list")
    public Map<String,String> getUser()
    {
        Map<String, String> m = new HashMap<>();
        List<KeysPo> keys =iKeysDao.getAll();
        keys.forEach((KeysPo e)->{
            m.put(e.key,e.value);
        });
        return m;
    }

    @GetMapping(value = "/actuator/info")
    @ResponseBody
    public String info(Model model)
    {
        return "this is from provider";
    }

}
